package com.apps.MobileSms.Aliyun.enums;

import lombok.Getter;

/**
 * 阿里云短信错误码
 */
@Getter
public enum SmsErrorCode {
    OK("OK", "短信接口调用成功", "短信发送成功!",0,0),
    UNEXPECTED_ERROR("UNEXPECTED_ERROR", "未知错误", "未知错误,请联系平台!",0,0),
    SMS_SIGNATURE_SCENE_ILLEGAL("isv.SMS_SIGNATURE_SCENE_ILLEGAL", "短信所使用签名场景非法", "短信系统异常,请联系平台!",0,0),
    EXTEND_CODE_ERROR("isv.EXTEND_CODE_ERROR", "扩展码使用错误，相同的扩展码不可用于多个签名", "短信系统异常,请联系平台!",0,0),
    DOMESTIC_NUMBER_NOT_SUPPORTED("isv.DOMESTIC_NUMBER_NOT_SUPPORTED", "国际/港澳台消息模板不支持发送境内号码", "国外消息不支持发送给国内",1,0),
    DENY_IP_RANGE("isv.DENY_IP_RANGE", "源IP地址所在的地区被禁用", "您所在的区域被禁止发送短信",1,0),
    DAY_LIMIT_CONTROL("isv.DAY_LIMIT_CONTROL", "触发日发送限额", "您今天发送的短信过多,请明天再发",1,0),
    SMS_CONTENT_ILLEGAL("isv.SMS_CONTENT_ILLEGAL", "短信内容包含禁止发送内容", "短信内容含有非法内容",1,0),
    SMS_SIGN_ILLEGAL("isv.SMS_SIGN_ILLEGAL", "签名禁止使用", "短信系统异常,请联系平台!",1,0),
    RAM_PERMISSION_DENY("isp.RAM_PERMISSION_DENY", "RAM权限DENY", "短信系统异常,请联系平台!",1,0),
    OUT_OF_SERVICE("isv.OUT_OF_SERVICE", "业务停机", "短信系统异常,请联系平台!",1,0),
    PRODUCT_UN_SUBSCRIPT("isv.PRODUCT_UN_SUBSCRIPT", "未开通云通信产品的阿里云客户", "短信系统异常,请联系平台!",1,1000),
    PRODUCT_UNSUBSCRIBE("isv.PRODUCT_UNSUBSCRIBE", "产品未开通", "短信系统异常,请联系平台!",1,0),
    ACCOUNT_NOT_EXISTS("isv.ACCOUNT_NOT_EXISTS", "账户不存在", "短信系统异常,请联系平台!",1,0),
    ACCOUNT_ABNORMAL("isv.ACCOUNT_ABNORMAL", "账户异常", "短信系统异常,请联系平台!",1,0),
    SMS_TEMPLATE_ILLEGAL("isv.SMS_TEMPLATE_ILLEGAL", "短信模板不合法", "短信系统异常,请联系平台!",1,0),
    SMS_SIGNATURE_ILLEGAL("isv.SMS_SIGNATURE_ILLEGAL", "短信模板签名不合法", "短信系统异常,请联系平台!",1,0),
    INVALID_PARAMETERS("isv.INVALID_PARAMETERS", "参数异常", "短信系统异常,请联系平台!",1,0),
    SYSTEM_ERROR("isp.SYSTEM_ERROR", "阿里云系统错误,需要重新调接口", "发生异常,请刷新页面重试",1,0),
    MOBILE_NUMBER_ILLEGAL("isv.MOBILE_NUMBER_ILLEGAL", "手机号非法", "不是合法的手机号",0,0),
    MOBILE_COUNT_OVER_LIMIT("isv.MOBILE_COUNT_OVER_LIMIT", "手机号码数量超过限制", "手机号码数量超过限制",1,0),
    TEMPLATE_MISSING_PARAMETERS("isv.TEMPLATE_MISSING_PARAMETERS", "模板缺少变量", "短信系统异常,请联系平台!",1,0),
    BUSINESS_LIMIT_CONTROL("isv.BUSINESS_LIMIT_CONTROL", "业务限流", "您短时间内发送的短信过多,清稍后再试",1,0),
    INVALID_JSON_PARAM("isv.INVALID_JSON_PARAM", "json参数不合法", "短信系统异常,请联系平台!",1,0),
    BLACK_KEY_CONTROL_LIMIT("isv.BLACK_KEY_CONTROL_LIMIT", "黑名单管控", "短信内容含有不允许发送的内容",1,0),
    PARAM_LENGTH_LIMIT("isv.PARAM_LENGTH_LIMIT", "参数超出长度限制", "短信系统异常,请联系平台!",1,0),
    PARAM_NOT_SUPPORT_URL("isv.PARAM_NOT_SUPPORT_URL", "不支持URL", "短信内容不允许发送url链接",1,0),
    AMOUNT_NOT_ENOUGH("isv.AMOUNT_NOT_ENOUGH", "账户余额不足", "短信系统异常,请联系平台!",1,0),
    TEMPLATE_PARAMS_ILLEGAL("isv.TEMPLATE_PARAMS_ILLEGAL", "模板变量包含非法关键字", "短信系统异常,请联系平台!",1,0),
    SignatureDoesNotMatch("SignatureDoesNotMatch", " 签名（Signature）加密错误。", "短信系统异常,请联系平台!",1,0),
    InvalidTimeStamp("InvalidTimeStamp.Expired", "一般由于时区差异造成时间戳错误，发出请求的时间和服务器接收到请求的时间不在15分钟内。", "您的手机时区跟服务器不一致",1,0),
    SignatureNonceUsed("SignatureNonceUsed", "唯一随机数重复，SignatureNonce为唯一随机数，用于防止网络重放攻击。", "短信系统异常,请联系平台!",1,0),
    InvalidVersion("InvalidVersion", "版本号（Version）错误。", "短信系统异常,请联系平台!",1,0),
    InvalidAction("InvalidAction.NotFound", "参数Action中指定的接口名错误。", "短信系统异常,请联系平台!",1,0),
    SIGN_COUNT_OVER_LIMIT("isv.SIGN_COUNT_OVER_LIMIT", "一个自然日中申请签名数量超过限制。", "短信系统异常,请联系平台!",1,0),
    TEMPLATE_COUNT_OVER_LIMIT("isv.TEMPLATE_COUNT_OVER_LIMIT", "一个自然日中申请模板数量超过限制。", "短信系统异常,请联系平台!",1,0),
    SIGN_NAME_ILLEGAL("isv.SIGN_NAME_ILLEGAL", "签名名称不符合规范。", "短信系统异常,请联系平台!",1,0),
    SIGN_FILE_LIMIT("isv.SIGN_FILE_LIMIT", "签名认证材料附件大小超过限制。", "短信系统异常,请联系平台!",1,0),
    SIGN_OVER_LIMIT("isv.SIGN_OVER_LIMIT", "签名字符数量超过限制。", "短信系统异常,请联系平台!",1,0),
    TEMPLATE_OVER_LIMIT("isv.TEMPLATE_OVER_LIMIT", "签名字符数量超过限制。", "短信系统异常,请联系平台!",1,0);

    private String errCode;

    private String desc;

    private String msg;

    /**
     * 表示如果发送短信返回这个错误码的话，是否重新发送
     * 1:需要
     * 0:不需要
     */
    private int isreSend;

    /**
     * 重试毫秒数，如果不需要重试默认为0
     */
    private int retrySeconds;

    SmsErrorCode(String errcode, String desc, String msg,int isreSend,int retrySeconds) {
        this.errCode = errcode;
        this.desc = desc;
        this.msg = msg;
        this.isreSend = isreSend;
        this.retrySeconds = retrySeconds;
    }

    /**
     * 根据错误码获取短信错误码实例
     * @param errCode 错误码
     * @return
     */
    public static SmsErrorCode getInstance(String errCode) {
        SmsErrorCode[] smsErrorCodes = values();
        for (SmsErrorCode smsErrorCode : smsErrorCodes) {
            if (smsErrorCode.getErrCode().equals(errCode)) {
                return smsErrorCode;
            }
        }
        return null;
    }

}